Skip to content

Conversation

ivmaykov
Copy link
Contributor

Fixes #3286

@ivmaykov
Copy link
Contributor Author

ivmaykov commented Oct 2, 2025

r? @emilio @pvdrz

@ivmaykov ivmaykov force-pushed the issue-3286 branch 4 times, most recently from aa5e696 to 7377020 Compare October 2, 2025 16:37
@ivmaykov
Copy link
Contributor Author

Is bindgen effectively unmaintained? What can I do to get this PR merged? Is this a controversial change? If so, can I have some feedback?

@emilio
Copy link
Contributor

emilio commented Oct 10, 2025

Bindgen is a free-time project for me, this PR was opened two weeks ago.

Please be patient because I unfortunately don't have a lot of free time lately :)

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but I don't think the hash set is going to be particularly worth it for derive lists in particular, and not doing that would simplify the code a bit, wdyt?

LMK if you disagree tho.

where
I: Iterator<Item = &'a str>,
{
// Use a HashSet to track already seen elements.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derive lists are usually pretty small, I don't think the copy + hashset overhead is going to be particularly worth it in this case...

That way the is_empty check on the caller can go. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Performance doesn't seem to matter and the new code is simpler.

.derive_partialord(false)
.derive_ord(false)
.derive_hash(false)
.parse_callbacks(Box::new(AddDerivesCallback::new(add_derives)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be less code to extend bindgen-integration perhaps? But this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not rewrite if this works :)

@ivmaykov
Copy link
Contributor Author

@emilio Totally understand about the time, sorry if I came across a bit rude, wasn't my intention.

Good point about hash set. I'm actually going to try benchmarking on our project. It's pretty large (generates a ~65k LoC rust file with thousands of bindings to a C library), and we actually use the add derives callback a bunch so I can see which one performs better.

Unfortunately, I can't test when rebased on top of main due to #3303 which I just filed. But I can rebase on top of an older commit that doesn't have that issue and test there, will report back.

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WFM, thanks!

@emilio
Copy link
Contributor

emilio commented Oct 13, 2025

BTW I'm totally cool with more people helping out with reviews and maintenance (thanks for filing that regression!)

@emilio emilio added this pull request to the merge queue Oct 13, 2025
Merged via the queue into rust-lang:main with commit 6d23680 Oct 13, 2025
51 checks passed
@ivmaykov
Copy link
Contributor Author

@emilio I don't think I have the bandwidth to sign up to be a maintainer, but will continue to file issues that I run across, and hopefully even fix some of them :)

@ojeda
Copy link
Contributor

ojeda commented Oct 13, 2025

One particularly useful way of helping maintainers (and thus getting PRs merged) is reviewing other PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ParseCallbacks::add_derives() should not cause a trait to be derived twice

3 participants